from typing import List, Union, Optional
from pydantic import BaseModel, Field, root_validator
from .common_model import Parcel, Address, ParcelDescAndValue, ExtraService, InvoiceAddress

"""
Belong--接收前端参数的类
Description--与核心的下单流程相关，这里的类都位于第一级别
"""

"""
NEW UI STEP ONE
"""


class StepOne(BaseModel):
    """
    第一步【添加收发件邮编，国家，包裹类型】
    """
    order_code: str = Field(None, description='订单CODE(主要用于第一步修改时使用)')
    edit_tag: bool = Field(default=False, description='修改标志')
    from_country: int = Field(..., description='发件国家ID')
    to_country: int = Field(..., description='收件国家ID')
    from_city_postal_code: int = Field(..., description='发件邮编')
    to_city_postal_code: int = Field(..., description='收件邮编')
    package_type: int = Field(..., description='包裹类型')


class StepTwo(BaseModel):
    """
    第二步【添加包裹】
    """
    edit_tag: bool = Field(False, description='修改标志')
    order_code: str = Field(..., description='订单CODE')
    parcel_list: List[Parcel] = Field(..., description='包裹列表')


"""
NEW UI STEP TWO
"""


class StepThree(BaseModel):
    """
    第三步【添加邮路】
    """
    order_code: str = Field(..., description='订单CODE')
    edit_tag: bool = Field(False, description='修改标志')
    mail_route_id: int = Field(..., description='邮路ID')


"""
NEW UI STEP THREE
"""


class StepFour(BaseModel):
    """
    第四步【填充包裹详情和增值服务】
    """
    order_code: str = Field(..., description='订单CODE')
    mail_route_id: int = Field(..., description='邮路ID')
    edit_tag: bool = Field(False, description='修改标志')
    parcel_list: List[ParcelDescAndValue] = Field(..., description='包裹列表【id,描述，价值】')
    value_added_list: ExtraService = Field(..., description='增值服务列表')


"""
NEW UI STEP FOUR
"""


class StepFive(BaseModel):
    """
   第五步【填充地址信息】
    """
    invoice_tag: bool = Field(False, description='是否需要发票')
    order_code: str = Field(..., description='订单CODE')
    edit_tag: bool = Field(False, description='修改标志')
    copy_from_sender: bool = Field(..., description='从发件复制')
    send_address: Address = Field(..., description='发件地址')
    receive_address: Address = Field(..., description='收件地址')
    invoice_address: InvoiceAddress = Field(..., description='发票邮寄地址')


"""
NEW UI STEP FIVE
"""


class EditAddress(BaseModel):
    """
    新UI第五步【编辑地址】
    """
    order_code: str = Field(..., description='订单编码')
    send_address: Address = Field(..., description='发件地址')
    receive_address: Address = Field(..., description='收件地址')


class StepSix(BaseModel):
    """
    第六步【支付】
    """
    order_code: str = Field(..., description='订单编码')
    pay_mode: int = Field(..., description='支付方式【0 支付宝支付 1 stripe支付】')
